package at.com.android.image;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.Toast;
public class MainActivity extends Activity {
	//private List<ImageItem> list_img;
	private ProgressDialog pd;
	private Gallery gy;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        gy = (Gallery) findViewById(R.id.gallery1);
        //Globals. list_img = new ArrayList<ImageItem>();
        pd = ProgressDialog.show(this, "Loading...", "Please Wait!", true, false);
        myThread mt = new myThread();
        Thread th = new Thread(mt);
        th.start();
    }
    
    public class myThread implements Runnable{
    	String output = "";

		public void run() {
			// TODO Auto-generated method stub
			
			
			handler.sendEmptyMessage(0);
		}
		private Handler handler = new Handler(){
			public void handleMessage(Message msg){
				pd.dismiss();
				ImageAdapter ia = new ImageAdapter(getApplicationContext(), Globals.list_img);
				gy.setAdapter(ia);
			}
		};
    	
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		menu.add("Select Image From SD Card");
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		Intent intnet = new Intent(MainActivity.this, ActivitySD.class);
		startActivity(intnet);
		Toast.makeText(this, "You selected", Toast.LENGTH_LONG).show();
		return super.onOptionsItemSelected(item);
	}

	
	
    
    
    
    
}